# 集合是无序的
"""
x = {'hello',1,'good'}
print(x)
"""
"""
x1 = {} # 这种是空的字典
x2 = {"姓名":"张三","age":19}
print(x2)
"""
# print(x[0]) # TypeError: 'set' object is not subscriptable
# 集合内容是唯一的
y = {1,1,'good','good'}
# print(y)

list2 = [12,12,88,848,28128,225,71,52,55,55,44]
# 需求：列表去重
# print(list(set(list2)))


# 创建一个空的集合
"""
y1 = {} # 空字典
print(type(y1)) #<class 'dict'>
y2 = set() # 创建了一个空集合
print(type(y2)) # <class 'set'>
"""
# 集合的增删改查
# 集合是可变的结构,没有顺序，里面的内容是唯一的
# 增
# a = {10,20,30,40,50}
"""
print(a)
a.add("侯雯中")
print(a)
"""
#删
# a.remove(50)
# print(a)

# a.pop() # 随机删除
# print(a)

# a.clear() # 清空
# print(a) # set()

# ss = set() # 创建空集合
# print(ss)
# 修改
# union ：a集合没有变化，返回值是一个新的集合
"""
b = a.union({10,20,30,40,50,60})
# 将a集合和后面的集合合到一起，传递给b
print(b) # {40, 10, 50, 20, 60, 30}
print(a) # {50, 20, 40, 10, 30}
# 将序列内容与旧集合合并到一起
"""
a1 = {10,20,30,40,50}
# a1.update([23,90,40]) # 列表
# a1.update((23,90,40)) # 元组
a1.update({23,90,40}) # 集合
# print(a1)
# 可迭代：集合、列表、字符串、元组、字典
"""
for i in a1:
    print(i)
"""
"""
for i in [10,20,30,40,50]:
    print(i)
"""
"""
for i in (10,20,30,40,50):
    print(i)
for i in {"name":"张三","age":19}:
    print(i)
"""
"""
for i in "test01":
    print(i)
"""
# 集合里运算符的使用
a = {'安其拉','李白','澜','镜','露娜','孙少香','鲁班大师','廉颇'}
b = {'夏洛特','镜','安其拉','李白','关羽','孙少香'}
# print(a-b)
# print(b - a)

# print(a & b) # 求a和b的交集
# print(a | b) # 求a和b的并集
# print(a ^ b) # 求a和b的差集的并集